package com.training.java.core.homework07.collections.laptop.post15;

public class Television {

	// Variables
	private boolean powerOn;
	private int volume;
	private String televisionName;
	private final int maxVolume = 100;
	private final int minVolume = 0;

	// Methods
	public Television(String televString) {
		this.powerOn = false; // instantiate with a default of false
		this.volume = 0;
		this.televisionName = televString;

		System.out.println("A Television object, " + this.televisionName
				+ " is instantiated with no power, volume = " + this.volume
				+ ".");
	}

	public void turnOn() {
		if (this.powerOn == false) {
			this.powerOn = true;
		}
		System.out.println("Television is turning on... .");
	}

	public void turnOff() {
		if (this.powerOn == true) {
			this.powerOn = false;
		}
		System.out.println("Television is turning off ... stopped now.");
	}

	public void increaseVolume(int volume) {
		if ((this.volume + volume) >= maxVolume) {
			this.volume = maxVolume;
		} else {
			this.volume += volume;
		}

		System.out.println("Volume of " + this.getTelevisionName()
				+ " increased " + " to " + this.volume);
	}

	public void decreaseVolume(int volume) {
		if ((this.volume - volume) <= minVolume) {
			this.volume = minVolume;
		} else {
			this.volume -= volume;
		}

		System.out.println("Volume of " + this.getTelevisionName()
				+ " decreased " + " to " + this.volume);
	}

	// Getters
	public boolean isPowerOn() {
		return this.powerOn;
	}

	public String getTelevisionName() {
		return televisionName;
	}

	public int getVolume() {
		return this.volume;
	}
}
